package com.ctgu.demo.controller;

import com.ctgu.demo.entity.Cake;
import com.ctgu.demo.service.CakeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin(allowCredentials = "true", allowedHeaders = "*")
@RestController
@RequestMapping("/cakes")
public class CakesController {

    @Autowired
    CakeService cakeService;

    @RequestMapping("/getCakeOne/{cakeId}")
    public Cake getCake(@PathVariable("cakeId") String cakeId){
        return cakeService.getById(cakeId);
    }
}
